<?php
$this->breadcrumbs=array(
	'社区'=>array('community/index'),
	$model->title,
);

//对所创建的话题超过一定时间无法更新
$time = $model->create_time+1200;
if(time()<$time){
$this->menu=array(
	array('label'=>'话题列表', 'url'=>array('index')),
	array('label'=>'更新贴子', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'删除贴子', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'管理贴子', 'url'=>array('admin')),
);
}
else{
	$this->menu=array(
	array('label'=>'话题列表', 'url'=>array('index')),
	array('label'=>'删除贴子', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'管理贴子', 'url'=>array('admin')),
);
}
?>

<h2><?php echo $model->title; ?></h2>

<span><?php echo CHtml::link($model->user->username, array('/user/view', 'id'=>$model->uid)); ?></span>
<span style = "margin-left: 5px">发表于<?php echo CHtml::encode(date('Y年m月d日H时i分',$model->create_time)); ?></span>
<span style = "margin-left: 5px"><?php echo CHtml::encode($model->visit); ?>次访问</span>

<div style = "background: #e4eef9; padding: 5px; margin-top: 5px;">
<?php echo $model->body; ?>
</div>

<hr />

<?php $this->widget('zii.widgets.CListView', array(
	'dataProvider'=>$dataProvider,
    'itemView'=>'_post',
	'emptyText'=>'当前没有回复',
)); ?>

<hr/>

<?php 
if (!Yii::app()->user->isGuest){
?>

<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'post-form',
	'enableAjaxValidation'=>false,
)); ?>

	<?php echo $form->errorSummary($post); ?>
	<div class="row">
			<?php 
			$this->widget('ext.ckeditor.CKEditorWidget',array(
			  "model"=>$post,                 # Data-Model
			  "attribute"=>'body',          # Attribute in the Data-Model
			  "defaultValue"=>$post->body,     # Optional
			  # Additional Parameter (Check http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html)
			  "config" => array(
			      "height"=>"100px",
			      "width"=>"94.7%",
			      "toolbar"=>"Basic",
			      ),
			  #Optional address settings if you did not copy ckeditor on application root
			  "ckEditor"=>Yii::app()->basePath."/../ckeditor/ckeditor.php",
			                                  # Path to ckeditor.php
			  "ckBasePath"=>Yii::app()->baseUrl."/ckeditor/",
			                                  # Realtive Path to the Editor (from Web-Root)
			  ) );
		?>
	
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($post->isNewRecord ? '回复' : '保存'); ?>
	</div>

<?php $this->endWidget(); ?>
</div><!-- form -->
<?php 
}
?>
